# coding=utf-8
import time

import allure
import jsonpath

from common.assert_operator import *
from common.db import *
from common.read_yaml import *
from common.utils import Utils

string_assert = string_assert() # 字符串校验类
pact = Pact() # 契约校验类
execute_sql = sql() # sql集合
utils = Utils()
data = ReadYaml_By_Root_Dict("case/99_outside_api_test/01_workflow_outside_test/99_01_7_GetSelectProcessModuleRecord_GetProcessModuleActionList.yml").get_yaml_data()  # 读取数据

@allure.feature('测试工作流外部接口：通过业务类型获取流程模板、获取流程模板状态')  # 测试报告显示测试功能
class Test_99_01_7_GetSelectProcessModuleRecord_GetProcessModuleActionList():
    """
    测试接口:
    /wf/api/processmodule/GetSelectProcessModuleRecord
    /wf/api/processmodule/GetProcessModuleActionList
    """

    # 获取yml文件中GetSelectProcessModuleRecord的数据参数
    Params = data['GetSelectProcessModuleRecord']
    # 获取yml的title，并作为ids的值传给用例
    ids_list = jsonpath.jsonpath(Params, "$[*][0]")
    @pytest.mark.parametrize("title, param, expect", Params, ids=ids_list)
    def test_GetSelectProcessModuleRecord(self, user_login, title, param, expect):
        allure.dynamic.description(f"{param['description']}")  # # 动态解析用例描述在测试报告中展示
        main = user_login.goto_Outside_Api()    # 进入外部接口类
        user_guid = utils.get_user_guid_by_code(param['user'])    #获取用户guid
        resp = main.GetSelectProcessModuleRecord(param['body'],user_guid)   #发起请求
        dict_assert(expect['response'],resp.json())    # 结果断言

    # 获取yml文件中GetProcessModuleActionList的数据参数
    Params = data['GetProcessModuleActionList']
    # 获取yml的title，并作为ids的值传给用例
    ids_list = jsonpath.jsonpath(Params, "$[*][0]")
    @pytest.mark.parametrize("title, param, expect", Params, ids=ids_list)
    def test_GetProcessModuleActionList(self, user_login, title, param, expect):
        allure.dynamic.description(f"{param['description']}")  # # 动态解析用例描述在测试报告中展示
        main = user_login.goto_Outside_Api()    # 进入外部接口类
        user_guid = utils.get_user_guid_by_code(param['user'])    #获取用户guid
        resp = main.GetProcessModuleActionList(param['body'],user_guid)   #发起请求
        dict_assert(expect['response'],resp.json())    # 结果断言
